<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"
	import="com.cdshop.entity.Cart,com.cdshop.dao.CartDAO,com.cdshop.web.PageUtil"%>
<%
	Long gid = new Long(request.getParameter("gid"));
	double price = Double.parseDouble(request.getParameter("price"));
	int qty = Integer.parseInt(request.getParameter("qty"));
	Long uid = PageUtil.loginUser(pageContext).getId();

	Cart cart = new Cart();
	cart.setGid(gid);
	cart.setUid(uid);
	cart.setPrice(price);
	cart.setQty(qty);
	cart.setTstamp(new java.sql.Date(new java.util.Date().getTime()));
	boolean ret = (CartDAO.instance().create(cart) != null);
	response.setContentType("text/jason");
	out.write(PageUtil.json().add("ret", ret).value());
	out.flush();
%>